<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>

<body>
    <script>
        //  一组数中的所有数的和平均值
        var arr = [1, 3, 4];
        var sum = 0;
        var avg;
        for (var i = 0; i < arr.length; i++) {
            sum += arr[i];
        }
        avg = sum / arr.length;
        console.log(avg);
        // 求一组数中的最大值
        var max = arr[0];
        for (var i = 1; i < arr.length; i++) {
            if (arr[i] > max) {
                max = arr[i]
            }
        }
        console.log(max)

        // 找到最大值的索引
        var max = arr[0];
        var maxIndex = 0;
        for (var i = 1; i < arr.length; i++) {
            if (max < arr[i]) {
                max = arr[i]
                maxIndex = i;
            }
        }

        
    </script>
</body>

</html>
